<?php 
/**
 * BAE相关设置选项
 * [WeEngine System] Copyright (c) 2013 WE7.CC
 */
if (checksubmit('bae_bucket') || checksubmit('bae_delete_update') || checksubmit('bae_delete_install')) {
	if (!empty($_GPC['bae_submit'])) {
		$config = file_get_contents(IA_ROOT . '/data/config.php');
		$config = preg_replace("/\\\$config\['bae'\].*?;/", '', $config);
		$config = preg_replace("/[\n\r]{5,}/", '', $config);
		$config .= PHP_EOL . "\$config['bae']['ak'] = '{$_GPC['bae_ak']}';";
		$config .= PHP_EOL . "\$config['bae']['sk'] = '{$_GPC['bae_sk']}';";
		$config .= PHP_EOL . "\$config['bae']['bucket'] = '{$_GPC['bae_bucket']}';";
		file_put_contents(IA_ROOT . '/data/config.php', $config);
	} elseif (!empty($_GPC['bae_delete_update'])) {
		unlink(IA_ROOT . '/data/update.lock');
	} elseif (!empty($_GPC['bae_delete_install'])) {
		unlink(IA_ROOT . '/data/install.lock');
	}
	message('操作成功！', create_url('setting/bae'), 'success');
} else {
	$nav['common'] = ' class="current"';
	template('setting/common');
}